﻿<UserControl x:Class="AutomationMLMapper.Controls.ImporterControl"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:MarkupExtensions="clr-namespace:AutomationMLMapper.Controls.MarkupExtensions"					 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
             xmlns:local="clr-namespace:AutomationMLMapper.Controls"
             xmlns:ConvertersAndTemplateSelectors="clr-namespace:AutomationMLMapper.Controls.ConvertersAndTemplateSelectors"
             xmlns:Properties="clr-namespace:AutomationMLMapper.Properties" mc:Ignorable="d" 
			 d:DesignHeight="312" d:DesignWidth="494">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/ListStyle.xaml"/>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/Templates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ConvertersAndTemplateSelectors:BoolToVisibilityConverter FalseValue="Collapsed" x:Key="btvc" />
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.InputBindings>
        <KeyBinding Command="{Binding LoadIHCommand}"  Gesture="Ctrl+E"/>
        <KeyBinding Command="{Binding LoadSystemCommand}" Gesture="Ctrl+I"/>
        <KeyBinding Command="{Binding MapIECommand}" Gesture="Ctrl+S"/>
        <KeyBinding Command="{Binding MapIEToClassCommand}" Gesture="Ctrl+C"/>
    </UserControl.InputBindings>
    
    <Grid>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding MappingListWidth, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"></ColumnDefinition>
            <ColumnDefinition Width="{Binding ImportListWidth, Source={x:Static Properties:Settings.Default}, Mode=TwoWay}"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Border Margin="1"  Grid.Row="0" Grid.ColumnSpan="2" BorderThickness="1" CornerRadius="1" BorderBrush="#FF565656">
            <Grid Margin="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0"  FontWeight="Bold" Margin="5,0,5,0" VerticalAlignment="Center">                                             
                    <Run Text="Name of the "/>
                    <Run Text="{Binding Path=SystemType}"/>
                </TextBlock>
                
                <TextBlock Grid.Column="1" Margin="0,0,5,0" Text="{Binding Path=Name}" VerticalAlignment="Center"></TextBlock>
                
                <StackPanel HorizontalAlignment="Right" Grid.Column="2" Orientation="Horizontal">

                    <ribbon:RibbonButton 
                                    SmallImageSource="{MarkupExtensions:ImageResolution Source=SCLib.ico, Size=24}" 
                                    Command="{Binding LoadSystemCommand}" 
                                    KeyTip="I"
                                    ToolTipImageSource="/AutomationMLMapper;component/Images/Info.ico"
					                ToolTipDescription="{x:Static Properties:Resources.TargetSystemAutomationMLDocumentDescription}" 
                                    ToolTipTitle="{x:Static Properties:Resources.TargetSystemAutomationMLDocument}">
                    </ribbon:RibbonButton>

                    <ribbon:RibbonButton SmallImageSource="{MarkupExtensions:ImageResolution Source=IH.ico, Size=24}" 
                                         Command="{Binding LoadIHCommand}" 
                                    KeyTip="E"
                                    ToolTipImageSource="/AutomationMLMapper;component/Images/Info.ico"
					                ToolTipDescription="{x:Static Properties:Resources.SourceSystemAutomationMLDocumentDescription}" 
                                    ToolTipTitle="{x:Static Properties:Resources.SourceSystemAutomationMLDocument}">
                    </ribbon:RibbonButton>

                    <ribbon:RibbonButton 
                                    SmallImageSource="/AutomationMLMapper;component/Images/SUCIEMapLarge.png" Command="{Binding MapIECommand}" 
                                    KeyTip="S"
                                    ToolTipImageSource="/AutomationMLMapper;component/Images/Info.ico"
					                ToolTipDescription="{x:Static Properties:Resources.ImportSimulationTipDescription}"  
                                    ToolTipTitle="{x:Static Properties:Resources.ImportSimulationTip}">
                    </ribbon:RibbonButton>

                    <ribbon:RibbonButton 
                                    SmallImageSource="/AutomationMLMapper;component/Images/SucSucMapLarge.png" Command="{Binding MapIEToClassCommand}" 
                                    KeyTip="C"
                                    ToolTipImageSource="/AutomationMLMapper;component/Images/Info.ico"
					                ToolTipDescription="{x:Static Properties:Resources.ClassToClassMappingTipDescription}"  
                                    ToolTipTitle="{x:Static Properties:Resources.ClassToClassMappingTip}">
                    </ribbon:RibbonButton>
                </StackPanel>
            </Grid>
        </Border>

        <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource HeaderTextBlock}" Text="{x:Static Properties:Resources.ListOfSystemUnitClasses}"></TextBlock>
        <ListView Grid.Row="2" Grid.Column="0" IsSynchronizedWithCurrentItem="True"
			 Name="ListOfSimulatedClasses"
                  VirtualizingStackPanel.IsVirtualizing="True"
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  ScrollViewer.IsDeferredScrollingEnabled="True"                  
			 ItemsSource="{Binding Path=ClassesCollection.View}" >
            <ListView.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="VerticalContentAlignment" Value="Top"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource ListGroupStyle}">
                </GroupStyle>
            </ListView.GroupStyle>

            <ListView.View>
                <GridView>
                    <GridViewColumn Width="Auto" CellTemplate="{StaticResource NameOutputTemplate}" HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{MarkupExtensions:ImageResolution Source=SC.ico, Size=24}"></Image>
                                    <TextBlock Margin="5,0,0,0" Text="SystemUnitClass"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                    </GridViewColumn>
                    <GridViewColumn x:Name="InstanceColumn" Width="Auto" HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <local:CollapsibleColumnHeader HeaderImageSource="/AutomationMLMapper;component/Images/IEI.ico"
															   ShowColumn="{Binding RelativeSource={RelativeSource AncestorType={x:Type GridViewColumnHeader}}, Mode=TwoWay, Path=DataContext.ShowInstanceOfClass}"
															   HeaderToolTip="Show imported Internal Element Instances of the SystemUnitClass" 
                                                               HeaderName="Imported Internal Element Instance" 
                                                               Column="{Binding ElementName=InstanceColumn}">
                                </local:CollapsibleColumnHeader>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>

                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <local:CAEXCollectionView HorizontalAlignment="Stretch" AllowAdd="False" AllowDelete="False"
													  Visibility="{Binding ElementName=ListOfSimulatedClasses, Path=DataContext.ShowInstanceOfClass, Converter={StaticResource btvc}}" 
													  DataContext="{Binding ImportedInstancesCollection}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource HeaderTextBlock}" Text="{x:Static Properties:Resources.ListOfExportedAutomationMLObjects}"></TextBlock>
        <GridSplitter Grid.Row="1" VerticalAlignment="Stretch" Background="#FF0C699D" Width="3"
                      Grid.RowSpan="2" ResizeDirection="Columns"></GridSplitter>
        <Grid Grid.Row="2" Grid.Column="1">
              <local:CAEXCollectionView HorizontalAlignment="Stretch" AllowAdd="False" AllowDelete="False" AllowEditElement="False"
                                      DataContext="{Binding ExportInstancesCollection}"/>
        </Grid>
    </Grid>
</UserControl>
